feat(redis): implement redis keys reset - #952
Open
tibo-pdn wants to merge 25 commits into
Open
Conversation
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
tibo-pdn
marked this pull request as ready for review
July 10, 2026 15:40
Resolved the merge conflicts and updated the branch by merging |
* fix: semgrep full * fix: release update
Co-authored-by: leoguillaume <62661249+leoguillaume@users.noreply.github.com>
Bumps [undici](https://github.com/nodejs/undici) from 7.25.0 to 7.28.0. - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](nodejs/undici@v7.25.0...v7.28.0) --- updated-dependencies: - dependency-name: undici dependency-version: 7.28.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Léo Guillaume <62661249+leoguillaume@users.noreply.github.com>
* refacto(keys): migrate GET /v1/admin/tokens to clean architecture as /v1/admin/keys. Add paginated list and get-by-id endpoints with use cases, repository, and tests; remove legacy GET handlers. Co-authored-by: Cursor <cursoragent@cursor.com> * Update unit coverage badge --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: leoguillaume <leoguillaume@users.noreply.github.com>
Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.13 to 7.5.21. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](isaacs/node-tar@v7.5.13...v7.5.21) --- updated-dependencies: - dependency-name: tar dependency-version: 7.5.21 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps and [svgo](https://github.com/svg/svgo). These dependencies needed to be updated together. Updates `svgo` from 4.0.1 to 4.0.2 - [Release notes](https://github.com/svg/svgo/releases) - [Commits](svg/svgo@v4.0.1...v4.0.2) Updates `svgo` from 3.3.3 to 3.3.4 - [Release notes](https://github.com/svg/svgo/releases) - [Commits](svg/svgo@v4.0.1...v4.0.2) --- updated-dependencies: - dependency-name: svgo dependency-version: 4.0.2 dependency-type: indirect - dependency-name: svgo dependency-version: 3.3.4 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
#968) * fix(cicd): install missing packages to run e2e tests and change documentation * Update unit coverage badge --------- Co-authored-by: leoguillaume <leoguillaume@users.noreply.github.com>
Bumps [sharp](https://github.com/lovell/sharp) from 0.34.5 to 0.35.0. - [Release notes](https://github.com/lovell/sharp/releases) - [Commits](lovell/sharp@v0.34.5...v0.35.0) --- updated-dependencies: - dependency-name: sharp dependency-version: 0.35.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…numeration (#963) * Added generic invalid credentials HTTP exception * Invalid password or user not found to raise new invalid creds exception * Fixed invalid creds integration tests * Removed unused InvalidPasswordHTTPException * Update unit coverage badge * Update unit coverage badge --------- Co-authored-by: Bakr Annour <dinum-304418@MacBook-Pro-de-DINUM-304418.local> Co-authored-by: bakr-a <bakr-a@users.noreply.github.com>
…#969) Co-authored-by: Cursor <cursoragent@cursor.com>
…ure (#962) * Refacto patch user * fix expires in users fastapi schemas * WIP: refacto update behavior * prevent password from being returned by fastapi * Update unit coverage badge * Update unit coverage badge --------- Co-authored-by: Benjamin PILIA <benjamin.pilia@protonmail.com> Co-authored-by: benjaminpilia <benjaminpilia@users.noreply.github.com> Co-authored-by: Léo Guillaume <62661249+leoguillaume@users.noreply.github.com> Co-authored-by: leoguillaume <leoguillaume@users.noreply.github.com>
…m:etalab-ia/OpenGateLLM into 704-reset-all-redis-keys-when-api-startup
…m:etalab-ia/OpenGateLLM into 704-reset-all-redis-keys-when-api-startup
# Conflicts: # api/utils/lifespan.py
…m:etalab-ia/OpenGateLLM into 704-reset-all-redis-keys-when-api-startup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Resolves #704.
Redis keys were not cleared when the API started. The only startup-time reset was
Limiter.reset()(called in the lifespan), which delegates to the
limitslibrary'sredis_storage.reset()— and thatonly deletes keys prefixed with
LIMITS(rate limiting). All the other keys written by the app(
ogl_mg:*inflight gauges,ogl_ts:*latency time-series) survived a restart.This PR flushes the whole Redis logical DB on API startup, once per process, from the gunicorn
master (
on_startinghook) before workers are forked. This placement is deliberate: with severalworkers in production, doing the flush in the per-worker lifespan would mean that a single crashed
worker being respawned by gunicorn would wipe the Redis state (rate limits, inflight gauges, metrics)
still in use by its live sibling workers — including driving the
inflightgauges negative. Running itonce in the master avoids that.
Changes:
Add
reset_redis_keys(url)inapi/utils/redis.py— a synchronousflushdb(the gunicorn masterruns outside the event loop).
Call it from
on_starting(server)inscripts/gunicorn.conf.py.Remove the now-redundant
Limiter.reset()method and its lifespan call (superseded by the full flush),and drop the associated obsolete unit tests.
All Redis keys are flushed when the API starts
The flush runs once per process (gunicorn master), so a crashed-worker respawn does not wipe the
shared Redis state of live workers
The obsolete
Limiter.reset()(partial, LIMITS-only reset) is removedBreaking changes:
Check lists
Review checklist
reset_redis_keys; the obsoleteLimiter.reset()unit tests were removed along with the method.api/utils/lifespan.pystill contains a commented-out# await client.flushdb()line to remove before merge.If
api/sql/models.pyhas been modified, please confirm that the following steps have been completed:Deployment checklist
For each of the following items, please confirm if the PR concerns the deployment of the changes:
Additional Notes
Points worth a reviewer's attention:
on_startinghookrather than the per-worker lifespan, specifically to avoid a respawned worker wiping the shared Redis
state of live sibling workers (rate-limit counters,
ogl_mg:*inflight gauges —decrement_inflighthas no floor at 0, so a mid-life flush could push gauges negative and skew the "least busy" load
balancer — and
ogl_ts:*metrics).A flush-on-start over a Redis shared across replicas is inherently in tension there; out of scope for
this PR, which targets the frequent and dangerous case (worker respawn).
same Redis URL/DB, so the startup flush also drops any queued Celery tasks/results.
# await client.flushdb()inapi/utils/lifespan.py.reset_redis_keys(seed keys → call → assertDBSIZE == 0) since the previous startup-reset unit tests were removed.